package com.flipped;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class IntentActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        Intent mIntent = getIntent();

        if(mIntent!=null){
            Toast.makeText(this,"原生：从js传过来的数据为："+mIntent.getStringExtra("params"),Toast.LENGTH_LONG).show();
        }

        Button btn_two = (Button)this.findViewById(R.id.textView);

        btn_two.setOnClickListener( new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                Intent mIntent = new Intent(IntentActivity.this,MainActivity.class);
                mIntent.putExtra("data","传入JS的数据。。。123");
                IntentActivity.this.setResult(Activity.RESULT_OK,mIntent);
                IntentActivity.this.finish();
            }
        });

    }
}
